package com.tbit.uqbike.client.service.impl;

import com.tbit.uqbike.client.dao.data.ReturnBikeMsgDao;
import com.tbit.uqbike.client.pojo.ReturnBikeMsg;
import com.tbit.uqbike.client.service.ReturnBikeMsgService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;

/**
 * @Author: chen
 * @Description:
 * @Date: 创建于 17:44 2020/11/24
 */
@Service
public class ReturnBikeMsgServiceImpl implements ReturnBikeMsgService {

    @Autowired
    private ReturnBikeMsgDao returnBikeMsgDao;

    @Override
    public ReturnBikeMsg getByOrderNO(String orderNO) {
        return returnBikeMsgDao.getByOrderNO(orderNO);
    }

    @Override
    public void add(ReturnBikeMsg returnBikeMsg) {
        returnBikeMsg.setAddTime(new Date());
        if (returnBikeMsg.getOrderNO() != null) {
            ReturnBikeMsg returnBikeMsgDB = getByOrderNO(returnBikeMsg.getOrderNO());
            if (returnBikeMsgDB != null) {
                returnBikeMsgDao.edit(returnBikeMsg);
            } else {
                returnBikeMsgDao.add(returnBikeMsg);
            }
        } else {
            returnBikeMsgDao.add(returnBikeMsg);
        }

    }

}
